package nc.bs.excel.translator;

import nc.pubitf.bd.accessor.GeneralAccessorFactory;
import nc.pubitf.bd.accessor.IGeneralAccessor;
import nc.vo.bd.accessor.IBDData;
import nc.vo.pfxx.exception.PfxxException;
import nccloud.bs.excel.ITranslateContext;
import nccloud.bs.excel.ITranslatorStrategy;

public class AccessorTranslatorWithOrgExt implements ITranslatorStrategy{
	public String getStrategyDescription() { return null; }

	public String translateExToNC(String srcValue, String metaDataID, ITranslateContext translateContext)
			throws PfxxException {
		IGeneralAccessor accessor = GeneralAccessorFactory.getAccessor(metaDataID);
		IBDData doc = null;
		doc = accessor.getDocByCode(getPk_org(translateContext), srcValue);
		if (doc == null) {
			doc = accessor.getDocByNameWithMainLang(getPk_org(translateContext), srcValue);
		}
		if (doc != null) {
			return doc.getPk();
		}
		return null;
	}

	public String getPk_org(ITranslateContext translateContext) {
		String pk_org = translateContext.getOrgPk();
		return pk_org;
	}
}
